package com.jlwl.houseservice.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jlwl.houseservice.common.Result;
import com.jlwl.houseservice.entity.SpecialService;
import com.jlwl.houseservice.service.SpecialServiceService;
import com.jlwl.houseservice.vo.SpecialServiceDetailVO;
import com.jlwl.houseservice.vo.SpecialServiceQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 特色服务控制器
 */
@RestController
@RequestMapping("/special-services")
public class SpecialServiceController {

    @Autowired
    private SpecialServiceService specialServiceService;

    /**
     * 获取特色服务列表
     */
    @GetMapping
    public Result<Page<SpecialService>> list(SpecialServiceQueryVO queryVO) {
        Page<SpecialService> page = specialServiceService.pageList(queryVO);
        return Result.success(page);
    }

    /**
     * 获取特色服务详情
     */
    @GetMapping("/{id}")
    public Result<SpecialServiceDetailVO> getDetail(@PathVariable Integer id) {
        SpecialServiceDetailVO detailVO = specialServiceService.getServiceDetail(id);
        if (detailVO == null) {
            return Result.error("特色服务不存在");
        }
        return Result.success(detailVO);
    }

    /**
     * 获取推荐特色服务列表
     */
    @GetMapping("/recommend")
    public Result<List<SpecialService>> getRecommendServices(@RequestParam(defaultValue = "6") Integer limit) {
        List<SpecialService> list = specialServiceService.getRecommendServices(limit);
        return Result.success(list);
    }

    /**
     * 根据分类获取特色服务列表
     */
    @GetMapping("/category/{categoryId}")
    public Result<List<SpecialService>> getServicesByCategory(
            @PathVariable Integer categoryId,
            @RequestParam(defaultValue = "10") Integer limit) {
        List<SpecialService> list = specialServiceService.getServicesByCategory(categoryId, limit);
        return Result.success(list);
    }
} 